-
Notifications
You must be signed in to change notification settings - Fork 439
Renamed isAt* funcs to at* in Parser and Parser.Lookahead #1996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thank you.
Decide if we need deprecated versions for non-private funcs
These functions aren’t public, so there’s no need for deprecation.
fileprivate mutating func isAtStartOfPostfixExprSuffix() -> Bool { | ||
fileprivate mutating func atStartOfPostfixExprSuffix() -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep the functions in Lexer.Cursor
in the isAt
style. The main checking function of Lexer.Cursor
also is is(offset: Int = 0, at: CharcterByte)
, so that fits with the isAt
style. The parser just uses at(_: TokenSpec)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! One sec, I'll clean this up.
@ahoppen, thank you for reviewing this! Cleaned up Lexer, so I think it should be good to go now. |
private func isAtStringInterpolationAnchor(delimiterLength: Int) -> Bool { | ||
private func atStringInterpolationAnchor(delimiterLength: Int) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I put the previous comment on the wrong line. I meant that we should keep the functions in Cursor.swift. Everything else should be renamed. I’m sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, mb, I should've read it more carefully too. Okay, so reverting this change, but renaming SwiftParser/Expressions.swift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 👍🏽
@swift-ci Please test |
Head branch was pushed to by a user without write access
@ahoppen cleaned it up. Parser and Parser.Lookahead use at* notation. Cursor is back to isAt* notation. |
@swift-ci Please test |
@swift-ci Please test Windows |
@ahoppen I see the formatting issues on the CI output, and I can clean them up. I'll build swift-format from main as you advised and work through them. |
Great. Thank you for fixing the formatting issue. Also: The macOS CI failure is unrelated to your changes. |
Head branch was pushed to by a user without write access
cdea2a8
to
9e8740e
Compare
My local |
OK, let’s try again. Also, just a note: We prefer to squash the commits of a PR because it just creates a nicer git history. I’ll put together some documentation with reasons for that in the upcoming days. @swift-ci Please test |
@ahoppen, agreed re: squashing — I usually end up doing that on the GitHub side when merging, but I'm happy to I usually keep commits separate to retain the step by step history of a PR while we're still talking through it, but once the review concludes, I can absolutely squash them. |
There's |
@swift-ci Please test Windows |
Yes, I think that would be a good idea as well. |
Head branch was pushed to by a user without write access
9e8740e
to
b76bdbd
Compare
Cleaned it up, and squashed into a single commit. |
@swift-ci Please test |
@swift-ci Please test Windows |
Motivation
Closes #1976. This pull request is a step towards making the Parser API consistent, and renaming some of the boolean
isAt*
functions withat*
.Changes
Lexer.Cursor.isAtStringInterpolationAnchor
— private, so I'll rename it and change any spots where it's invoked. Deprecating the existing function should not be necessary.Lexer.Cursor.isAtEscapedNewline
— same as above.Parser.Lookahead
has two fileprivate functionsisAtStartOfPostfixExprSuffix
andisInBindingPatternPosition
— I think it's best to rename both of them so the code in that particular extension is consistent. It would be weird to haveatStartOfPostfixExprSuffix
andisIn*
.Parser.isAtPythonStyleInheritanceClause
SwiftParser/Statements.swift
we haveParser.Lookahead
extension withisAtStartOfSwitchCase
,isStartOfStatement
,isStartOfConditionalSwitchCases
.isStartOf*
as well for consistency?SwiftParser/Types.swift
hasParser.Lookahead.isAtFunctionTypeArrow
— also not marked as private.TODO